/**
 * 获取年月日 星期 时分
 */
export function getDate(time) {
  let date = time ? new Date(time) : new Date();
  let year = date.getFullYear();
  let month =
    date.getMonth() + 1 < 10
      ? "0" + (date.getMonth() + 1)
      : date.getMonth() + 1;
  let day = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
  let hours = date.getHours() < 10 ? "0" + date.getHours() : date.getHours();
  let minutes =
    date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes();
  let seconds =
    date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();
  let week = date.getDay();
  let weekStr = "";
  if (week == 0) {
    weekStr = "星期日";
  } else if (week == 1) {
    weekStr = "星期一";
  } else if (week == 2) {
    weekStr = "星期二";
  } else if (week == 3) {
    weekStr = "星期三";
  } else if (week == 4) {
    weekStr = "星期四";
  } else if (week == 5) {
    weekStr = "星期五";
  } else if (week == 6) {
    weekStr = "星期六";
  }
  return {
    date: year + "-" + month + "-" + day,
    time: hours + ":" + minutes + ":" + seconds,
    week: weekStr,
  };
}
